/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colorfulcircles;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import org.ianaz.Chess;
import org.ianaz.logic.Cell;
import org.ianaz.logic.Game;
import org.ianaz.logic.Human;
import org.ianaz.logic.Player;

/**
 *
 * @author s.rainoldi
 */
public class ColorfulCircles extends Application {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Player p1 = new Human();
        p1.setColor(Chess.Color.WHITE);
        Player p2 = new Human();
        p2.setColor(Chess.Color.BLACK);
        Game g = new Game(p1, p2);


        Group root = new Group();
        Scene scene = new Scene(root, 640, 640, Color.BLACK);
        primaryStage.setScene(scene);
        Group rects = new Group();
        int cellSize = 80;
        for (int i = 0; i < g.getCells().length; i++) {
            for (int l = 0; l < g.getCells()[i].length; l++) {
                Group rect = new Group();
                Cell c = g.getCells()[i][l];
                Color cw = Color.web("white");
                if (c.getColor() == Chess.Color.BLACK) {
                    cw = Color.web("black");
                }
                Rectangle rrect = new Rectangle(cellSize, cellSize, cw);
                rrect.setX(l * cellSize);
                rrect.setY(i * cellSize);
                rect.getChildren().add(rrect);
                rects.getChildren().add(rect);
            }
        }
        root.getChildren().add(rects);
        primaryStage.setResizable(false);
        primaryStage.show();
    }
}
